package com.yaaha.config;

import com.yaaha.properties.MyProperties;
import com.yaaha.service.MyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动配置类
 */
@Configuration
@ConditionalOnWebApplication
@EnableConfigurationProperties(MyProperties.class)
public class MyServiceAutoConfiguration {
    @Autowired
    MyProperties myProperties;

    @Bean
    public MyService myService(){
        MyService myService = new MyService();
        myService.setMyProperties(myProperties);
        return myService;
    }
}
